package com.dianrui.moonfire.activity;

import android.os.Handler;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.dianrui.moonfire.R;
import com.dianrui.moonfire.util.EventBusConstants;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 支付完成界面
 */

public class PaySuccessActivity extends BaseActivity {
    @BindView(R.id.title)
    TextView title;

    @Override
    public int getContentViewId() {
        return R.layout.activity_paysuccess;
    }

    @Override
    public void initView() {
        customInit(true);
        title.setText(getString(R.string.pay_result));
        EventBus.getDefault().post(EventBusConstants.PAYSUCCESSRFRESHLOCATION);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                JumpKillActivitys(MainActivity.class);
            }
        }, 800);
    }

    @Override
    public void initData() {

    }

    @OnClick(R.id.back)
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                EventBus.getDefault().post(EventBusConstants.PAYSUCCESSRFRESHLOCATION);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        JumpKillActivitys(MainActivity.class);
                    }
                }, 800);
                break;

                default:
                    break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            EventBus.getDefault().post(EventBusConstants.PAYSUCCESSRFRESHLOCATION);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    JumpKillActivitys(MainActivity.class);
                }
            }, 800);

        }
        return super.onKeyDown(keyCode, event);
    }


}
